import React, { Component } from "react"

export default function withDemo(WrappedComponent) {
  return class Demo extends Component {
    static displayName = "with" + WrappedComponent.name

    state = {
      username: "",
      password: "",
      repassword: "",
    }

    handleChange = (name) => {
      return (e) => {
        this.setState({
          [name]: e.target.value,
        })
      }
    }

    render() {
      return (
        <WrappedComponent
          {...this.state}
          handleChange={this.handleChange}
        ></WrappedComponent>
      )
    }
  }
}
